#include "case01.h"

static void trigger_stack_overflow(void)
{
    //stack overflow
    uint8_t big_array[1024 * 1024]; 
    big_array[0] = 0xaa;
}

void case_01(void)
{
    uint32_t index = 0;
    uint16_t pin = 0xffff;
    uint8_t bit = 0;
    while (1)
    {
        pin = (uint16_t)(1 << (bit++));
        if(bit > 7)
            bit = 0;
        HAL_GPIO_TogglePin(GPIOA, pin);

        //time= 20ms*300=6s
        //enter hardfault
        if(index > 300)
        {
            trigger_stack_overflow();
        }

        index++;
        HAL_Delay(20);
    }
}
